package com.person.monitor;

import static com.person.monitor.helper.VolumeHelper.COMMAND_ALARM_MAX;
import android.content.Context;
import android.media.AudioManager;
import com.person.monitor.helper.VolumeHelper;
import java.util.List;

public class AlarmVolumeProcess extends BaseProcess {

    AudioManager audioManager;

    int maxVolume;


    public AlarmVolumeProcess(Context context, String name) {
        super(context, name);

        audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM);
    }

    @Override
    public void processMonitor(List<MonitorInfo> list) {
        MonitorInfo monitorInfo = list.get(0);

        if(monitorInfo.time > 700 && monitorInfo.time < 900){
            checkAlarmVolume();
        }
    }

    private void checkAlarmVolume(){
        int volume = audioManager.getStreamVolume(AudioManager.STREAM_ALARM);

        if(volume < maxVolume) {
            VolumeHelper.getInstance().startActivityCommand(COMMAND_ALARM_MAX);
        }
    }
}
